Harden MCP pagination against cursor cycles and add go-sdk registration canaries#4302
Merged
Harden MCP pagination against cursor cycles and add go-sdk registration canaries#4302
Conversation
5 tasks
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/4d4e8792-d37a-4028-8eaa-15752f44b0d7 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Agent-Logs-Url: https://github.com/github/gh-aw-mcpg/sessions/4d4e8792-d37a-4028-8eaa-15752f44b0d7 Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Review Go module modelcontextprotocol/go-sdk
Harden MCP pagination against cursor cycles and add go-sdk registration canaries
Apr 21, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens MCP backend pagination and strengthens test canaries around go-sdk tool registration behavior, reducing the risk of runaway pagination and catching SDK upgrade regressions early.
Changes:
- Add cursor-cycle detection to
paginateAllso repeated cursors fail fast with an explicit error. - Extend pagination tests to cover cyclical cursors and keep the max-pages cap test focused on the cap path.
- Clarify HTTP transport protocol/session handling comments and extend routed-mode tool registration canary to ensure schema-invalid arguments still reach handlers.
Show a summary per file
| File | Description |
|---|---|
| internal/mcp/connection.go | Add seenCursors tracking to detect cursor cycles during pagination and return a clear error. |
| internal/mcp/connection_test.go | Add a cyclical-cursor test and adjust the max-pages test to use unique cursors. |
| internal/mcp/http_transport.go | Clarify MCPProtocolVersion scope and document why string-matching remains for session-missing detection in plain JSON fallback. |
| internal/server/routed_test.go | Strengthen the registerToolWithoutValidation canary using a strict schema and intentionally schema-invalid arguments. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 4/4 changed files
- Comments generated: 0
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This updates the go-sdk integration points highlighted in the review: production pagination now fails fast on cyclical cursors, and upgrade-sensitive behavior around tool registration is covered by a stronger canary. It also clarifies transport-specific protocol/session handling to reduce future maintenance ambiguity.
Pagination safety in
internal/mcp/connection.gopaginateAllusing aseenCursorsset.Pagination behavior coverage in
internal/mcp/connection_test.goTestPaginateAllthat verifies early termination on repeated cursors.Transport-scope clarity in
internal/mcp/http_transport.goMCPProtocolVersionapplies to the plain JSON-RPC fallback path only.isSessionNotFoundErrorfor string fallback matching when SDK typed errors are unavailable.SDK-upgrade canary for schema-validation bypass in
internal/server/routed_test.goTestRegisterToolWithoutValidationwith a strict-schema tool and intentionally schema-invalid arguments.registerToolWithoutValidation/Server.AddToolpath still invokes handlers without SDK argument-value validation regressions.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
example.com/tmp/go-build2010847725/b513/launcher.test /tmp/go-build2010847725/b513/launcher.test -test.testlogfile=/tmp/go-build2010847725/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2010847725/b423/vet.cfg rotocol/go-sdk@v1.5.0/jsonrpc/jsonrpc.go -trimpath x_amd64/vet gci-lint failed /opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet 7457537/b209/sym-atomic -lang=go1.25 x_amd64/vet -p g_.a 477457537/b287//-ifaceassert x_amd64/vet -I go-sdk/mcp 7457537/b287/ x_amd64/vet(dns block)/tmp/go-build81877103/b513/launcher.test /tmp/go-build81877103/b513/launcher.test -test.testlogfile=/tmp/go-build81877103/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s rds/�� lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_git lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_commit -guard/target/debug/deps/rustco0oSqi/symbols.o -guard/target/debash b0d7 -guard/target/de--noprofile -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.03.rcgu.o -gua�� -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.05.rcgu/opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.06.rcgu/tmp/go-build3709670566/b506/vet.cfg -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.07.rcgu.o -guard/target/debash -guard/target/de--norc -guard/target/de--noprofile -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.11.rcgu.o(dns block)invalid-host-that-does-not-exist-12345.com/tmp/go-build2010847725/b495/config.test /tmp/go-build2010847725/b495/config.test -test.testlogfile=/tmp/go-build2010847725/b495/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2010847725/b397/vet.cfg @v1.1.3/cpu/x86/-c=4 ggXp/9qGZEHgmklo-nolocalimports x_amd64/vet --gdwarf-5 nal/encoding/tag-atomic -o x_amd64/vet 7457�� g_.a ache/go/1.25.9/x-ifaceassert x_amd64/vet -I /opt/hostedtoolc-atomic -I x_amd64/vet(dns block)nonexistent.local/tmp/go-build2010847725/b513/launcher.test /tmp/go-build2010847725/b513/launcher.test -test.testlogfile=/tmp/go-build2010847725/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2010847725/b423/vet.cfg rotocol/go-sdk@v1.5.0/jsonrpc/jsonrpc.go -trimpath x_amd64/vet gci-lint failed /opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet 7457537/b209/sym-atomic -lang=go1.25 x_amd64/vet -p g_.a 477457537/b287//-ifaceassert x_amd64/vet -I go-sdk/mcp 7457537/b287/ x_amd64/vet(dns block)/tmp/go-build81877103/b513/launcher.test /tmp/go-build81877103/b513/launcher.test -test.testlogfile=/tmp/go-build81877103/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s rds/�� lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_git lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_commit -guard/target/debug/deps/rustco0oSqi/symbols.o -guard/target/debash b0d7 -guard/target/de--noprofile -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.03.rcgu.o -gua�� -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.05.rcgu/opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.06.rcgu/tmp/go-build3709670566/b506/vet.cfg -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.07.rcgu.o -guard/target/debash -guard/target/de--norc -guard/target/de--noprofile -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.11.rcgu.o(dns block)slow.example.com/tmp/go-build2010847725/b513/launcher.test /tmp/go-build2010847725/b513/launcher.test -test.testlogfile=/tmp/go-build2010847725/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp/go-build2010847725/b423/vet.cfg rotocol/go-sdk@v1.5.0/jsonrpc/jsonrpc.go -trimpath x_amd64/vet gci-lint failed /opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet 7457537/b209/sym-atomic -lang=go1.25 x_amd64/vet -p g_.a 477457537/b287//-ifaceassert x_amd64/vet -I go-sdk/mcp 7457537/b287/ x_amd64/vet(dns block)/tmp/go-build81877103/b513/launcher.test /tmp/go-build81877103/b513/launcher.test -test.testlogfile=/tmp/go-build81877103/b513/testlog.txt -test.paniconexit0 -test.timeout=10m0s rds/�� lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_git lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_commit -guard/target/debug/deps/rustco0oSqi/symbols.o -guard/target/debash b0d7 -guard/target/de--noprofile -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.03.rcgu.o -gua�� -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.05.rcgu/opt/hostedtoolcache/go/1.25.9/x64/pkg/tool/linux_amd64/vet -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.06.rcgu/tmp/go-build3709670566/b506/vet.cfg -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.07.rcgu.o -guard/target/debash -guard/target/de--norc -guard/target/de--noprofile -guard/target/debug/deps/serde_derive-bdc7cd22a58a5141.serde_derive.12123747d8da05ed-cgu.11.rcgu.o(dns block)this-host-does-not-exist-12345.com/tmp/go-build2010847725/b522/mcp.test /tmp/go-build2010847725/b522/mcp.test -test.testlogfile=/tmp/go-build2010847725/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s abis�� cfg -I x_amd64/vet --gdwarf-5 ce -o x_amd64/vet cfg 7457537/b449/_pkg_.a nLJk/a4JpKmHiBmr_E514nLJk x_amd64/vet --gdwarf-5 ntio/asm/keyset -o x_amd64/vet(dns block)/tmp/go-build81877103/b522/mcp.test /tmp/go-build81877103/b522/mcp.test -test.testlogfile=/tmp/go-build81877103/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s lib/�� lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_git lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_commit lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_-m lib/rustlib/x86_bash b0d7 lib/rustlib/x86_--noprofile lib/rustlib/x86_/home/REDACTED/.rustup/toolchains/stable-x86_64-REDACTED-linux-gnu/lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libminiz_oxide-2b6a8d2f6e1dc71b.rlib lib/�� lib/rustlib/x86_64-REDACTED-linux-gnu/lib/librustc_std_workspace_alloc-76b5fe9328c1063f.rlib lib/rustlib/x86_64-REDACTED-linux-gnu/lib/libminiz_oxide-2b6a8d2f6e1dc71b.rlib iginal -f "$GOPATH/bin/bash -I yload_StoredInPa--noprofile -guard/target/debug/deps/libserde_derive-bdc7cd22a58a5141.so(dns block)/tmp/go-build1985989918/b522/mcp.test /tmp/go-build1985989918/b522/mcp.test -test.testlogfile=/tmp/go-build1985989918/b522/testlog.txt -test.paniconexit0 -test.timeout=10m0s /tmp�� /run/containerd/-p herFiles,CFiles,main by/31b594e5b708d-lang=go1.25 ntime.v2.task/mogit -guard/target/deshow -guard/target/de7291de63ecded2ae0119c7bba93a1d428d68106a:internal/server/routed_test.go 296/log.json b2f7�� 081a786f99487854go1.25.9 y er-linux ntime.v2.task/mo/opt/hostedtoolcache/CodeQL/2.25.1/x64/codeql/tools/linux64/java/lib/jspawnhelper /tmp/awmg-log-te21.0.9+10-LTS --routed er-linux(dns block)If you need me to access, download, or install something from one of these locations, you can either: